﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace MvcApp.Web {
	public static class HtmlExtensions {
		public static MvcHtmlString ActionLinkForNavBar(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName) {
			var tLi = new TagBuilder("li");
			var tCurrentController = htmlHelper.ViewContext.RouteData.Values["controller"] as string;
			if (tCurrentController == controllerName) {
				tLi.MergeAttribute("class", "active");
			}
			tLi.InnerHtml = htmlHelper.ActionLink(linkText, actionName, controllerName).ToHtmlString();
			return MvcHtmlString.Create(tLi.ToString());
		}
	}
}